<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>

        function createDiv(){
            this.div = document.createElement('div');
            document.body.appendChild(this.div);
        }

        createDiv.prototype.show = function(text){
            this.div.innerHTML = text;
        }
        const single = (function(){
            let instance = null;
            return function(text){
                if(!instance){
                    instance = new createDiv();
                }

                instance.show(text);
                return instance;
            }
        })()

        const single1 = single('我是div1');
        const single2 = single('我是div2');
        console.log(single1 === single2);

    </script>
</body>
</html>